package com.xe.map;

import java.io.InputStream;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.Drawable;

import com.baidu.mapapi.map.*;
import com.baidu.platform.comapi.basestruct.GeoPoint;

import com.xe.icard.Config;
import com.xe.icard.R;

/**
 * 邀请地点的覆盖物
 * 
 * @author xujh
 * 
 */
public class PlaceOverlay extends ItemizedOverlay<OverlayItem> {

	private Context mContext;
	private OverlayItem o1;

	public PlaceOverlay(Drawable marker, Context context) {
		//super(boundCenterBottom(marker));
		super(marker);
		this.mContext = context;
	 
		// 用给定的经纬度构造GeoPoint，单位是微度 (度 * 1E6)
		GeoPoint p1 = new GeoPoint((int) (Config.LATITUDE * 1E6), (int) (Config.LONGITUDE * 1E6));
	 
		o1 = new OverlayItem(p1, "P1", "point1");
		populate(); //createItem(int)方法构造item。一旦有了数据，在调用其它方法前，首先调用这个方法
	}

	@Override
	protected OverlayItem createItem(int arg0) {
		return o1;
	}

	@Override
	public int size() {
		return 1;
	}

	// private Bitmap mRawImage;
	// private Paint mPaint = new Paint();
	// private GeoPoint mP = null;
	//
	// public PlaceOverlay(Context context, GeoPoint p) {
	// super();
	// this.mP = p;
	// InputStream inputStream = context.getResources().openRawResource(
	// R.drawable.invitation_place);
	// if (null != inputStream) {
	// mRawImage = BitmapFactory.decodeStream(inputStream);
	// }
	// }
	//
	// @Override
	// public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	// Point point = mapView.getProjection().toPixels(mP, null);
	// canvas.drawBitmap(mRawImage, point.x - mRawImage.getWidth()/2, point.y -
	// mRawImage.getHeight()/2, mPaint);
	// }

}
